# -*- coding: utf-8 -*-
""""-----------------Item家具类----------------"""
class Item:
    def __init__(self,name,area):
        self.name = name
        self.area = area

    def __repr__(self):
        return 'repr家具类型：{},家具占用面积：{}'.format(self.name,self.area)

"""------------------House房子类---------------"""
class House:
    def __init__(self,address,area):
        self.address = address
        self.area = area
        #剩余面积
        self.free_area = self.area
        #家具列表
        self.items = []

    def __str__(self):
        return '房子地址：{},占地面积：{},剩余面积：{}'.format(self.address,self.area,self.free_area)

    def add_item(self,item):
        if self.free_area >= item.area:
            self.items.append(item)
            self.free_area -=item.area
            print('添加成功')
        else:
            print('面积不足，无法添加家具')

item1 = Item('桌子',40)
item2 = Item('沙发',10)
item3 = Item('家庭影院',80)
print(item1)
print(item2)
print(item3)

house =House('西沙胡花园',100)
print(house)

print('-'*50)
house.add_item(item1)
house.add_item(item2)
house.add_item(item3)
print(house)
print("所有家具：",house.items)
